/*
 *------------------------------------------------------------------------------
 * @File      :    ei_mai_venc.h
 * @Date      :    2021-4-8
 * @Author    :    lomboswer <lomboswer@lombotech.com>
 * @Brief     :    Media Interface for MADP(Media Development Platform).
 *
 * Copyright (C) 2020-2021, LomboTech Co.Ltd. All rights reserved.
 *------------------------------------------------------------------------------
 */

#ifndef __EI_MAI_VENC_H__
#define __EI_MAI_VENC_H__


#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
#include "ei_mai_venc_define.h"
/**
 * @brief create video ENC instance
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] pstVencAttr EI_MADP_VENC_ATTR_S: the attribute of VENC instance
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_Init(EI_HANDLE hVencHdl, const EI_MADP_VENC_ATTR_S *pstVencAttr);

/**
 * @brief destroy video ENC instance
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_DeInit(EI_HANDLE hVencHdl);

/**
 * @brief register call back for VENC instance
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] pstVencCB EI_VENC_CALLBACK_S: call back function of VENC
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_RegisterCallback(EI_HANDLE hVencHdl, EI_VENC_CALLBACK_S *pstVencCB);

/**
 * @brief unregister call back for VENC instance
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] pstVencCB EI_VENC_CALLBACK_S: call back function of VENC
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_UnRegisterCallback(EI_HANDLE hVencHdl, EI_VENC_CALLBACK_S *pstVencCB);

/**
 * @brief start video ENC instance
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] EI_S32 EI_MADP_VENC_ATTR_S: the frame count of VENC will to do; EI_VENC_LIMITLESS_FRAME_COUNT :VENC Will not automatically stop
 * 			N( N > 0) :VENC will automatically stop after encode N frame data.
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_Start(EI_HANDLE hVencHdl, EI_S32 s32FrameCnt);

/**
 * @brief stop video ENC instance
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_Stop(EI_HANDLE hVencHdl);

/**
 * @brief VENC link video video port
 * @param[in] hIPPUHdl EI_HANDLE: handle of video processor
 * @param[in] hVPortHdl EI_HANDLE: handle of video port
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_Link_IPPU(EI_HANDLE hIPPUHdl, EI_HANDLE hVPortHdl, EI_HANDLE hVencHdl);

/**
 * @brief VENC unlink video video port
 * @param[in] hIPPUHdl EI_HANDLE: handle of video processor
 * @param[in] hVPortHdl EI_HANDLE: handle of video port
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_UnLink_IPPU(EI_HANDLE hIPPUHdl, EI_HANDLE hVPortHdl, EI_HANDLE hVencHdl);

/**
 * @brief set video ENC attribute
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] pstStreamAttr EI_MADP_VENC_ATTR_S: the attribute of VENC instance
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_SetAttr(EI_HANDLE hVencHdl, EI_MADP_VENC_ATTR_S *pstStreamAttr);

/**
 * @brief get video ENC attribute
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[out] pstStreamAttr EI_MADP_VENC_ATTR_S: the attribute of VENC instance
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_GetAttr(EI_HANDLE hVencHdl, EI_MADP_VENC_ATTR_S *pstStreamAttr);

/**
 * @brief request IDR frame
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_RequestIDR(EI_HANDLE hVencHdl);

/**
 * @brief get stream head information
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] enType EI_VENC_HEAD_INFO_TYPE_E: the type of head information
 * @param[out] pcHeadInfo EI_CHAR: the point of head information
 * @param[in/out] pu32HeadInfoLength EI_U32:length of pcHeadInfo
 * @return Non 0 indicate create failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_GetStreamHeadInfo(EI_HANDLE hVencHdl, EI_VENC_HEAD_INFO_TYPE_E enType,
             EI_CHAR *pcHeadInfo, EI_U32 *pu32HeadInfoLength);

/**
 * @brief set thumb nail attribute
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] pstThumbNailAttr EI_THUMBNAIL_ATTR_S: the attribute of thum nail
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_SetThumbNailAttr(EI_HANDLE hVencHdl,EI_SNAP_SCREENNAIL_ATTR_S *pstThumbNailAttr);

/**
 * @brief create video ENC instance
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[out] pstThumbNailAttr EI_THUMBNAIL_ATTR_S: the attribute of thum nail
 * @return Non 0 indicate failed
 * @return  0 indicate success
 */
EI_S32 EI_MAI_VEnc_GetThumbNailAttr(EI_HANDLE hVencHdl,EI_SNAP_SCREENNAIL_ATTR_S* pstThumbNailAttr);
/** @}*/  /** <!-- ==== ENC End ====*/

/**
 * @brief set video ENC extend attribute
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] enCMD EI_MADP_VENC_CMD_E: command of set VENC extend attribute
 * @param[in] pstAttrEx VENC_ATTREX_S: the extend attribute of VENC instance
 * @return Non 0 indicate set failed
 * @return  0 indicate set success
 */
EI_S32 EI_MAI_VEnc_SetAttrEx(EI_HANDLE hVEncHdl, EI_MADP_VENC_CMD_E enCMD, VENC_ATTREX_S *pstAttrEx);

/**
 * @brief get video ENC extend attribute
 * @param[in] hVencHdl EI_HANDLE: handle of VENC
 * @param[in] enCMD EI_MADP_VENC_CMD_E: command of get VENC extend attribute
 * @param[out] pstAttrEx VENC_ATTREX_S: the extend attribute of VENC instance
 * @return Non 0 indicate get failed
 * @return 0 indicate get success
 */
EI_S32 EI_MAI_VEnc_GetAttrEx(EI_HANDLE hVEncHdl, EI_MADP_VENC_CMD_E enCMD, VENC_ATTREX_S *pstAttrEx);

/**
 * @brief Set osd attribute.
 * @param[in] hVencHdl EI_HANDLE:handle of video encode.
 * @param[in] hVOsdHdl EI_HANDLE:handle of osd region:[0,EI_VENC_OSD_MAX_NUM).
 * @param[in] pstOsdAttr EI_MADP_OSD_ATTR_S:Osd attribute.Some of them are dynamic.Details are described in EI_MADP_OSD_ATTR_S.
 * @return Non 0 indicate get failed
 * @return 0 indicate get success
 */
EI_S32 EI_MAI_VEnc_OSD_SetAttr(EI_HANDLE hVencHdl, EI_HANDLE hVOsdHdl, EI_MADP_OSD_ATTR_S* pstOsdAttr);

/**
 * @brief Get osd attribute.
 * @param[in] hVencHdl EI_HANDLE:handle of video encode.
 * @param[in] hVOsdHdl EI_HANDLE:handle of osd region:[0,EI_VENC_OSD_MAX_NUM).
 * @param[out] pstOsdAttr EI_MADP_OSD_ATTR_S*:pointer of Osd attribute
 * @return Non 0 indicate get failed
 * @return 0 indicate get success
 */
EI_S32 EI_MAI_VEnc_OSD_GetAttr(EI_HANDLE hVencHdl, EI_HANDLE hVOsdHdl, EI_MADP_OSD_ATTR_S *pstOsdAttr);

/**
 * @brief Start osd instance.
 * @param[in] hVencHdl EI_HANDLE:handle of video encode.
 * @param[in] hVOsdHdl EI_HANDLE:handle of osd region:[0,EI_VENC_OSD_MAX_NUM).
 * @return Non 0 indicate get failed
 * @return 0 indicate get success
 */
EI_S32 EI_MAI_VEnc_OSD_Start(EI_HANDLE hVencHdl, EI_HANDLE hVOsdHdl);

/**
 * @brief Stop osd instance.Osd region will be destroyed from capture.
 * @param[in] hVencHdl EI_HANDLE:handle of video encode.
 * @param[in] hVOsdHdl EI_HANDLE:handle of osd region:[0,EI_VENC_OSD_MAX_NUM).
 * @return Non 0 indicate get failed
 * @return 0 indicate get success
 */
EI_S32 EI_MAI_VEnc_OSD_Stop(EI_HANDLE hVencHdl, EI_HANDLE hVOsdHdl);

EI_S32 EI_MAI_VEnc_CropEncode(EI_HANDLE hVencHdl, VIDEO_FRAME_INFO_S *pstFrame, EI_MADP_VENC_CROP_ATTR_S *pstClipAttr);

EI_S32 EI_MAI_VEnc_EnableCropEncode(EI_HANDLE hVencHdl);

EI_S32 EI_MAI_VEnc_EnableSnapEncode(EI_HANDLE hVencHdl);

EI_S32 EI_MAI_VEnc_RetainStream(EI_HANDLE hVencHdl, EI_VENC_DATA_S*);

EI_S32 EI_MAI_VEnc_ReleaseStream(EI_HANDLE hVencHdl, EI_VENC_DATA_S*);

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

#endif /* __EI_MAI_VENC_H__ */

